package own.stu.jobgib.playown.juc.activeObject;

import own.stu.jobgib.playown.juc.activeObject.result.Result;
import own.stu.jobgib.playown.juc.activeObject.service.ActiveObject;

public class MakeStringThread extends Thread {
    private final ActiveObject activeObject;
    private final char fillChar;

    public MakeStringThread(String name, ActiveObject activeObject) {
        super(name);
        this.activeObject = activeObject;
        this.fillChar = name.charAt(0);
    }

    @Override
    public void run() {
        for (int i = 0; true; i++) {
            Result<String> result = activeObject.makeString(i, fillChar);
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String value = result.getResultValue();
            System.out.println(Thread.currentThread().getName() + ": value = " + value);
        }
    }
}
